

<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="exportExcel" action="exportExport">
        <div class="form-group">


            <div class="form-group">
                <label class="col-sm-3 control-label">约修类型：</label>
                <div class="col-sm-8">
                    <span>水质</span>
                </div>
            </div>



            <label class="col-sm-3 control-label">约修因子：</label>
            <div class="col-sm-8">
                <input name="ele_name" value="氨氮" type="checkbox"><span>氨氮</span>
                <input name="ele_name" value="水温" type="checkbox"><span>水温</span>
                <input name="ele_name" value="叶绿素" type="checkbox"><span>叶绿素</span>
                <input name="ele_name" value="浊度" type="checkbox"><span>浊度</span>
                <input name="ele_name" value="总磷" type="checkbox"><span>总磷</span>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">约修因子参数：</label>
            <div class="col-sm-8">
                <input name="factor" value="平均值" type="checkbox"><span>平均值</span>
                <input name="factor" value="最大值" type="checkbox"><span>最大值</span>
                <input name="factor" value="最小值" type="checkbox"><span>最小值</span>
                <input name="factor" value="排放量" type="checkbox"><span>排放量</span>
            </div>
            <div><input type="submit" class="btn btn-warning">
                <i class="fa fa-download"></i>
           </div>
        </div>
    </form>

</div>


<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="importExcel">
        <div class="form-group">


            <div class="form-group">
                <label class="col-sm-3 control-label">第一步：</label>
                <div class="col-sm-8">
                    <span>根据需求选择要约修的因子及因子参数后，生成约修表格</span>
                </div>
            </div>



            <label class="col-sm-3 control-label">第二步：</label>
            <div class="col-sm-8">
                <span>在生成的表格中填写相关的数据</span>
            </div>
        </div>


        <div class="form-group">
            <label class="col-sm-3 control-label">第三步：</label>
            <div class="col-sm-8">
                <span>选择所填好的表格并上传</span>
               <!-- <div>   <a class="btn btn-info" onclick="$.table.importExcel()">
                    <i class="fa fa-upload"></i> 导入
                </a></div>-->



                <div class="row" id="div3" style="width:450px;">
                    <input type="hidden" name="excelUrl"  id="excelUrl"/>
                    <a href="javascript:void(0);" class="btn_addPic">
                        <input type="file" name="logoFile" id="logoFile" onchange="setImg(this);" class="selectedLogoImgId">
                    </a>
                    <input type="hidden" name="excelUrlShow" id="excelUrlShow" style="width: 315px;">
                </div>
                <!--读取excel-->
                <input type="submit" class="searchbtn search" value="导入用户信息" onclick="insertExcel()">




            </div>
        </div>

    </form>
</div>



<th:block th:include="include :: footer" />
<script>


    function setImg(obj){//用于进行excel上传，返回地址
        var f=$(obj).val();
        if(f == null || f ==undefined || f == ''){
            return false;
        }
        if(!/\.(?:xls|xlsx)$/.test(f))
        {
            alertLayel("类型必须是excel表格(.xls|xlsx)格式");
            $(obj).val('');
            return false;
        }
        var data = new FormData();
        $.each($(obj)[0].files,function(i,file){
            data.append('file', file);
        });
        $.ajax({
            type: "POST",
            url: "/KaiTong/uploadImg.html",
            data: data,
            cache: false,
            contentType: false,    //不可缺
            processData: false,    //不可缺
            dataType:"json",
            success: function(suc) {
                if(suc.code==0){
                    $("#excelUrl").val(suc.message);//将地址存储好
                    $("#excelUrlShow").val(suc.message);//显示excel
                }else{
                    alertLayel("上传失败");
                    $("#url").val("");
                    $(obj).val('');
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alertLayel("上传失败，请检查网络后重试");
                $("#url").val("");
                $(obj).val('');
            }
        });
    }








    /**
     * 导入excel数据
     */
    function insertExcel(){
        var url = $("#excelUrlShow").val();
        if(url == null || url == ''){
            alertLayel("请选择Excel文件");
            return false;
        }
        $.ajax({
            type: "POST",
            url: "/KaiTong/insertUserExcel.html?url="+url,
            cache: false,
            contentType: false,
            processData: false,
            dataType:"json",
            success: function(obj) {
                var total = obj.result.total;
                var num = obj.result.num;
                var shibai = total - num;
                if(obj.code == 1){
                    alertLayel("一共"+total+"条数据,成功导入"+num+"条数据,失败"+shibai+"条数据");//成功
                }else if(obj.code == 2){
                    alertLayel(obj.message);//失败
                }else if(obj.code == 3){
                    alertLayel("Excel中没有数据");//无数据
                }
                else if(obj.code == 0){
                    alertLayel("系统异常,请稍候操作");
                }
            },
            error: function(XMLHttpRequest, textStatus, errorThrown) {
                alertLayel("上传失败，请检查网络后重试");
                $("#url").val("");
                $(obj).val('');
            }
        });
    }




</script>
<!--
<script th:inline="javascript">
    var prefix = ctx + "bus/audit";
    var datas = [[${@dict.getType('BusDataAudit')}]];

    $(function() {
        var options = {
            importUrl: prefix + "/templateExport",
            importTemplateUrl: prefix + "/templateExport",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            search: true,
            modalName: "用户",
            columns: [{
                checkbox: true
            },

                {
                    field : 'eleName',
                    title : '因子名称'
                },
                {
                    field : 'avgValue',
                    title : '平均值'
                },
                {
                    field : 'maxValue',
                    title : '最大值'
                },
                {
                    field : 'minValue',
                    title : '最小值'
                },
                {
                    field : 'couValue',
                    title : '排放量'

                }]
        };
        $.table.init(options);
    });
</script>-->




</body>
<!--<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>

            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>-->
</html>